package com.konoha.mapper;

import com.konoha.pojo.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * (Article)表数据库访问层
 *
 * @author makejava
 * @since 2024-05-04 20:53:17
 */

@Mapper
public interface ArticleMapper  {

    //新增
    @Insert("insert into article(title, content, cover_img,state, category_id, create_user, create_time, update_time,student_id,name,score,time_taken) " +
            "values(#{title},#{content},#{coverImg},#{state},#{categoryId},#{createUser},#{createTime},#{updateTime},#{studentId},#{name},#{score},#{timeTaken})")
    void add(Article article);

    //分页查询
    List<Article> list(Integer userId, Integer categoryId, String state);

    //查询
    @Select("select * from article where id=#{id}")
    Article findById(Integer id);

    //更新
    @Update("update article set title=#{title},content=#{content},cover_img=#{coverImg},state=#{state}," +
            "category_id=#{categoryId},update_time=#{updateTime},student_id=#{studentId},name=#{name},score=#{score},time_taken=#{timeTaken} " +
            "where id=#{id}")
    void update(Article article);

    //删除
    @Delete("delete from article where id=#{id}")
    void delete(Integer id);

    //添加识别成绩信息
    @Insert("insert into article(create_user, create_time, update_time,student_id,name,score,time_taken,cover_img,category_id) values" +
            "(#{createUser},#{createTime},#{updateTime},#{studentId},#{name},#{score},#{timeTaken},#{coverImg},#{categoryId}) ")
    void addScore(Article article);
}
